/**
 * Created with JetBrains PhpStorm.
 * User: Sergey
 * Date: 19.09.13
 * Time: 13:10
 * To change this template use File | Settings | File Templates.
 */
function initMenuAccordion() {
    var menuAccordion = $('.menu-accordion').accordion({
        heightStyle:'fill',
        icons: {
            "header":"ui-icon-grey-triangle",
            "activeHeader":"ui-icon-blue-triangle"
        }
    });
}

function initNumberedLists() {
    var lists = $('.custom-numbered-list');
    lists.each(function() {
        var marks = $('li .mark', $(this));
        marks.each(function(index) {
            $(this).text(index+1);
        });
    });
}

function initAppearanceHorizontalListItem() {
    var listImageBtnDescrItem = $('.hor-list-item.img-btns-descr-item');
    var listImageBtnHiddenDescrItem = $('.hor-list-item.img-btns-descr-item.item-hidden-descr');

    // Hide buttons and description (if need) on init
    $('.list-item-buttons', listImageBtnDescrItem).slideUp();
    $('.description', listImageBtnHiddenDescrItem).slideUp();

    listImageBtnDescrItem.hover(
        function() {
            $('.list-item-buttons', $(this)).slideDown();
            $('.description .title', $(this)).addClass('hovered');
        }, function() {
            //$('.list-item-buttons', $(this)).slideUp();
            $('.list-item-buttons', $(this)).hide();
            $('.description .title', $(this)).removeClass('hovered');
        }
    );

    listImageBtnHiddenDescrItem.hover(
        function() {
            $('.description', $(this)).slideDown();
        }, function() {
            //$('.list-item-descr', $(this)).slideUp();
            $('.description', $(this)).hide();
        }
    );
}

$(function () {
    initMenuAccordion();
    initNumberedLists();
    initAppearanceHorizontalListItem();
});